﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Collections.Generic;
using ScrumTable.Common;

#endregion

namespace ScrumTable.DL.Data.Schema
{
    /// <summary>
    /// Specifies a schema entry with a single name and no child schemata
    /// elements.
    /// </summary>
    public class NamedSchema : SchemaBase
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        private readonly Type _schemaType;
        
        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        /// <summary>
        /// Returns true if the type of the current Schema corresponds to the
        /// type of the representing value.
        /// </summary>
        public override bool HasSchemaValueType
        {
            get { return true; }
        }

        /// <summary>
        /// Specifies the type of the schema element.
        /// </summary>
        public override Type SchemaType
        {
            get { return _schemaType; }
        }

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        /// <summary>
        /// Creates a new NamedSchema instance.
        /// </summary>
        /// <param name="schemaType">Specifies the type of the schema element.</param>
        /// <param name="allowedValues">Specifies a range with allowed values, which may be overwritten in the Schema.xml file.</param>
        /// <param name="defaultValue">Specifies a value with the default value, which may be overwritten in the Schema.xml file.</param>
        /// <param name="isSchemaReference">Determines whether the current schema element references on another schema element or not.</param>
        /// <param name="isReadOnly">Determines whether the current schema element references on another schema element or not.</param>
        public NamedSchema(Type schemaType, IEnumerable<object> allowedValues = null, object defaultValue = null, bool isSchemaReference = false, bool isReadOnly = false)
        {
            PreCondition.AssertNotNull(schemaType, "schemaType");

            _schemaType = schemaType;
            IsSchemaElementReadOnly = isReadOnly;
            IsSchemaReference = isSchemaReference;

            SchemaAllowedValues = allowedValues;
            SchemaDefaultValue = defaultValue;
        }

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion
    }
}
